package com.example.myapplication;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class rate extends AppCompatActivity {
    private static final String TAG="rate";
    private TextView score1;
    private TextView score2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_rate);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
        score1 = findViewById(R.id.v2);
        score2 = findViewById(R.id.v4);
    }
    public  void click(View bt){
        Log.i(TAG,"click:3333333");
        String s1=(String) score1.getText();
        int sc1=Integer.parseInt(s1);
        String s2=(String) score1.getText();
        int sc2=Integer.parseInt(s2);
        if(bt.getId()==R.id.bt1){
            sc1 += 3;
        } else if (bt.getId()==R.id.bt2) {
            sc1 += 2;
        }else if (bt.getId()==R.id.bt3) {
            sc1 += 1;
        }if(bt.getId()==R.id.bt7) {
            sc1 = 0;
        }
        score1.setText(String.valueOf(sc1));
        if (bt.getId()==R.id.bt4) {
            sc2 += 3;
        }else if (bt.getId()==R.id.bt5) {
            sc2 += 2;
        }else if (bt.getId()==R.id.bt6) {
            sc2 += 1;
        }
        if(bt.getId()==R.id.bt7){
            sc2=0;
        }
        score2.setText(String.valueOf(sc2));
    }
}